package com.hst.capacity.infra.persistence.jpa.order.job;

import com.hst.capacity.domain.model.entity.order.job.JobPlatformEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

public interface JobPlatformRepository extends JpaRepository<JobPlatformEntity, String > {

    JobPlatformEntity findByIdDriver(String idDriver);

    JobPlatformEntity findByIdTask(String idTask);

    @Transactional(rollbackFor = Exception.class)
    @Modifying
    @Query("update JobPlatformEntity t set t.status = ?1 where t.idDriver = ?2")
    int updateJobStatus(int status, String idDriver);

}